#ifndef SERIESSIMPLE_H
#define SERIESSIMPLE_H

#include "SeriesBase.h"

// A series extrapolator which just does the simple sum

template <class T> 
class SeriesSimple : public virtual SeriesBase<T>
{
#define INITVECS(n) \
    do { \
        if (doerrcalc) ds.reserve(n); \
    } while (false)
public:
    SeriesSimple(uint n=20, bool _doerrcalc=true, bool _saveterms=true) : 
        SeriesBase<T>(n,_doerrcalc,_saveterms) 
    { INITVECS(n); }

    SeriesSimple(const vector<T>& v, bool _doerrcalc=true,
                 bool _saveterms=true) : 
        SeriesBase<T>(v.size(),_doerrcalc,_saveterms)
    { INITVECS(v.size()); AddTerms(v); }

    SeriesSimple(const vector<T>& v, const vector<T>& verr, 
                 bool _doerrcalc=true, bool _saveterms=true) : 
        SeriesBase<T>(v.size(),_doerrcalc,_saveterms)
    { INITVECS(v.size()); AddTerms(v,verr); }

    ~SeriesSimple() {}
#undef INITVECS

protected:
    void CalcResult(const T& term);
    const T& GetResult() const {return PlainSum();}
    const vector<T>& GetDSum() const 
    {
        while(ds.size() < NTerms()) ds.push_back(1.);
        return ds;
    }


private:
    mutable vector<T> ds;
};

template <class T>
inline void SeriesSimple<T>::CalcResult(const T& term) { }

#endif
